package core2.ch01file.iostream;
import java.io.*;
public class ConsoleStream {
	public static void main(String[] args) {
		
		System.out.println(System.getProperty("user.name"));
		
		InputStream is =System.in;
		DataInputStream dis=new DataInputStream(is);
		
		//OutputStream os =System.out;
		//DataOutputStream dos =new DataOutputStream(os);
		
		byte[] bytes=new byte[100];
		try {
			int count =dis.read(bytes);
			for (int i = 0; i < count-2; i++) {
				System.out.print(" "+(char)bytes[i]);
			}
			System.out.println();
		} catch (Exception e) {
			// TODO: handle exception
		}
		int n =100;
		try {
			FileInputStream fis =new FileInputStream(System.getProperty("user.dir")+"\\src\\core2\\ch01file\\iostream\\ConsoleStream.java");
			while((fis.read(bytes, 0, n)!=-1)&&(n>0)){
				System.out.print(new String(bytes));
			}
			System.out.println();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		try {
			is.close();
			dis.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
